<%@ page contentType="text/html;charset=UTF-8" %> 
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title><spring:message code="company_account_createBankAccount"/></title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script type="text/javascript">
    
 
    $(document).ready(function(){
		 var form = $("#inputForm");  
	        form.validate();//验证指定的表单
	        
	        
	        	$("#createButton").click(function(){
	        		if (form.valid()) {//如果表单验证成功，则进行提交。  
	        			createAccount();
	                	
	                return false
	              }
	         });
	        
	    });
   
    function createAccount(){
    	//获取 iframe 数量 
     	var frLength = window.parent.frames.length;
     	//父画面下标 
     	var parentIndex = frLength-2;
    	var index = $("#index").val();
		var frameObj = window.parent.frames[parentIndex].document.getElementById("perantTable");
    	/* 删除该行  */
    	if (index!=null && index!="") {
    			
    		$(frameObj)[0].rows[index].remove();
			
		}
    	
    	/* 追加新的一行 */
		var bankAliias = $("#bankAliias").val();
		var bankName = $("#bankName").val();
		var bankPointName = $("#bankPointName").val();
		var bankAccountNo = $("#bankAccountNo").val();
		var isDefault = $("input:radio:checked").val();
		var yesOrNo ;
		if (isDefault==1) {
			yesOrNo = "<spring:message code="company_account_defaultAccount"/>";
		}else{
			yesOrNo = "<spring:message code="company_account_notDefaultAccount"/>";
		}
		var userName = $("#userName").val();
		var createAccountDate = $("#createAccountDate").val().toString();
		var createAccountDateDB = $("#createAccountDateDB").val()
		var createAccountUser = $("#createAccountUser").val().toString();
		var newhidden = '<input type="hidden" id="bankAliiasHere" name="bankAliiasHere" value="'+bankAliias+'"><input type="hidden" id="bankNameHere" name="bankNameHere" value="'+bankName+'"><input type="hidden" id="bankPointNameHere" name="bankPointNameHere" value="'+bankPointName+'"><input type="hidden" id="bankAccountNoHere" name="bankAccountNoHere" value="'+bankAccountNo+'"><input type="hidden" id="isDefaultHere" name="isDefaultHere" value="'+isDefault+'"><input type="hidden" id="createAccountUserHere" name="createAccountUserHere" value="'+createAccountUser+'"><input type="hidden" id="createAccountDateHere" name="createAccountDateHere" value="'+createAccountDate+'"></tbody>';
		var newRow = ' <tbody> <tr><td  class="table-gszhcz"><img src="${ctxStatic}/images/btn-bj.png" height="30" width="30" onclick="addBankCheck(this)">&nbsp;&nbsp;<img src="${ctxStatic}/images/btn-sc.png" height="30" width="30"  onclick="deleteCurrentRow(this)"></td><td class="table-gszhzhbc" >'+bankAliias+'</td><td class="table-gszhkhmc" >'+bankName+'</td><td class="table-gszhkhzh" >'+bankAccountNo+'</td><td class="table-gszhkhwd" >'+bankPointName+'</td><td class="table-gszhzhlx">'+yesOrNo+'</td><td class="table-gszhkhr" >'+userName+'</td><td class="table-gszhkhsj" >'+createAccountDateDB+'</td>'+newhidden+'</tr>';
		
		
		$(frameObj).append(newRow);
		
		
		closeWin();

    }
    </script>
</head>
<body>
<form id="inputForm">   
<div class="layerHeader clearfix">
<c:choose>
    <c:when test="${companyList.index!=null && companyList.index!='' }">
    		<p class="headerTitle"><spring:message code="company_account_editBankAccount"/></p>
    </c:when>
      <c:otherwise>
      		<p class="headerTitle"><spring:message code="company_account_createBankAccount"/></p>
      </c:otherwise>  
    </c:choose>
	
    <div class="headerButton clearfix">
    <c:choose>
    <c:when test="${companyList.index!=null && companyList.index!='' }">
    		<button type="button" id="createButton"><spring:message code="company_account_save"/></button>
    </c:when>
      <c:otherwise>
      		<button type="button" id="createButton"><spring:message code="company_account_create"/></button>
      </c:otherwise>  
    </c:choose>
        <button type="button" onclick="closeWin()"><spring:message code="company_account_cancle"/></button>
    </div>
</div>

<div class="tabBoxSm">
    <div class="tabSm smOrderBox">
        <input type="hidden" id="createAccountDate" name="createAccountDate" value="${fns:getDate('yyyy-MM-dd HH:mm')}">
    	<input type="hidden" id="createAccountUser" name="createAccountUser" value="${fns:getUser()}">
    	<input type="hidden" id="createAccountDateDB" name="createAccountDateDB" value="${fns:getDate('yyyy-MM-dd HH:mm')}">
    	<input  type="hidden" id="userName" name="userName" value="${companyList.currentUser.firstName}${companyList.currentUser.lastName}">
    	<input type="hidden" id="index" name="index" value="${companyList.index}">
        <div class="clearfix">
        	<div class="left">
            	<div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="company_account_bankAliias"/></p>
                    <input id="bankAliias" name="bankAliias" style="width: 300px" maxlength="100" value="${companyList.bankAliias}" data-rule-required="true" data-msg-required="<spring:message code="company_account_err_msg_bankAliias"/>">
                    <p class="haveTo">*</p>
                </div>
               
                <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="company_account_bankName"/></p>
                    <input id="bankName" name="bankName" style="width: 300px" maxlength="100" value="${companyList.bankName}" data-rule-required="true" data-msg-required="<spring:message code="company_account_err_msg_bankName"/>">
                   <p class="haveTo">*</p>
                </div>
                
                <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="company_account_bankPointName"/></p>
                    <input id="bankPointName" name="bankPointName" style="width: 300px" maxlength="100" value="${companyList.bankPointName}" data-rule-required="true" data-msg-required="<spring:message code="company_account_err_msg_bankPointName"/>">
                    <p class="haveTo">*</p>
                </div>
                <div class="items clearfix haveToBox">
                	<p class="tit"><spring:message code="company_account_bankAccountNo"/></p>
                    <input id="bankAccountNo" name="bankAccountNo" style="width: 300px" maxlength="100" value="${companyList.bankAccountNo}" data-rule-required="true" data-msg-required="<spring:message code="company_account_err_msg_bankAccountNo"/>">
                    <p class="haveTo">*</p>
                </div>
                <div class="items clearfix">
                	<p class="tit"><spring:message code="company_account_isDefault"/></p>
                				
                                    <div class="labelBox">
                                    <label>
                                        <input type="radio" style="width:20px;" id="yes" name="isDefault" value="1"  <c:if test="${companyList.isDefault eq 1 ||companyList.isDefault eq null}"> checked="checked"</c:if>>
                                        <spring:message code="company_account_yes"/>
                                       </label>
                                       <label>
                                        <input type="radio" style="width:20px;" id="no" name="isDefault" value="0"  <c:if test="${companyList.isDefault eq 0}"> checked="checked"</c:if>>
                                        <spring:message code="company_account_no"/>
                                   		</label>
                                   		</div>
                                  
                                  
                </div>
            </div>
           
       
        </div> 
	</div>
 </div>   
</form>
<script>
</script>
</body>
</html>
